package com.situ.blog.service.impl;


import com.situ.blog.dao.IBlogTypeDao;
import com.situ.blog.dao.impl.BlogTypeDaoImpl;
import com.situ.blog.pojo.entity.BlogType;
import com.situ.blog.pojo.query.BlogTypeQuery;
import com.situ.blog.pojo.vo.BlogTypeCountVO;
import com.situ.blog.service.IBlogTypeService;
import com.situ.blog.util.LayUITableResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogTypeServiceImpl implements IBlogTypeService {
    @Autowired
    private IBlogTypeDao blogTypeDao;

    //业务：为了封装PageInfo，查询两次数据库
    @Override
    public LayUITableResult selectByPage(BlogTypeQuery blogTypeQuery) {
        List<BlogType> list = blogTypeDao.selectByPage(blogTypeQuery);
        Integer totalCount = blogTypeDao.selectTotalCount(blogTypeQuery);

        return LayUITableResult.ok(totalCount, list);
    }

    @Override
    public void deleteById(BlogType blogType) {
        blogTypeDao.deleteById(blogType);
    }

    @Override
    public void add(BlogType blogType) {
        blogTypeDao.add(blogType);
    }

    @Override
    public List<BlogTypeCountVO> selectBlogTypeCount() {
        return blogTypeDao.selectBlogTypeCount();
    }

}
